﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
namespace GUI
{
    public partial class FrmLogin : DevExpress.XtraEditors.XtraForm
    {
        public FrmLogin()
        {
            InitializeComponent();
            UserLookAndFeel.Default.SetSkinStyle("Xmas 2008 Blue");
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text != "")
            {

                UserAccount user = UserAccount.getUser();
                if (user.CheckUser(txtUsername.Text,txtPassword.Text) == 1)
                {
                    this.Hide();
                    (new Main(user.isAdmin(), txtUsername.Text)).ShowDialog();
                    
                }
                else
                    MessageBox.Show("Sai Tên Tài Khoản Hoặc Mật Khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((Keys)e.KeyChar == Keys.Enter)
                btnDangNhap_Click(null, null);
        }

    
    }
}